#pragma once

#include <list>
#include <vector>
#include <map>
#include "TrueText/Types.h"

namespace TrueText {

struct Word
{
	bool IsEnterchar;
	bool IsWhitespace;
	wchar_t const* WordStart;
	size_t WordLength;

    Word()
		: IsEnterchar(false)
		, IsWhitespace(false)
		, WordStart(0)
		, WordLength(0)
	{ }
};

struct Line
{
	Line()
	{ }

	Line(const Line& rhs)
		: Words(rhs.Words)
	{ }

    const Line& operator=(const Line& rhs)
	{
		if (this == &rhs)
			return *this;

		Words = rhs.Words;

		return *this;
	}


	std::list<Word> Words;
};

struct WordMetrics
{
    Dimensions Bounds;
   	// Offset of a baseline from the bottom of the bounds
	int Baseline;
	// Offset from the top of the line to the top of the bitmap
    int VOffset;
	int BearingX;

	std::vector<int> LetterPositions;

    WordMetrics()
        : Baseline(0)
        , VOffset(0)
		, BearingX(0)
    { }
};

struct LineMetrics
{
    int Width;
    std::list<WordMetrics> Words;

    LineMetrics()
        : Width(0)
    { }
};

/** Used only for atlas layouts, includes bounding boxes for all symbols as well as advances and bearings */
struct LetterMetrics
{
	/** Index within the string used to construct atlas */
	Point origin;
	/** Advance to next letter in FT Points */
	int advance;
	Rectangle bounds;
};

struct AtlasMetrics
{
	int LineHeight;
	Point Offset;
	std::map<wchar_t, LetterMetrics> Letters;
};

}